import {MyNavBar, ShowLoading} from '@/components'
import {useListHook} from '@/hooks'
import {_getOrderList} from './store'
import OrderItem from './components/orderItem'
import {history} from 'umi'

import './index.less'

function Order() {
  const {data, showLoading} = useListHook({func: _getOrderList})

  return (
    <div>
      <MyNavBar title='我的订单'/>
      <div className='orders'>
        {data?.length ? data.map(item => (
          <OrderItem data={item} key={item.id} handleClick={(id) => {
            history.push({pathname: '/order/order', query: {id}})
          }}/>
        )) : ''}
        <ShowLoading showLoading={showLoading} />
      </div>
    </div>
  )
}

export default Order
